package com.powervision.mvvmdemo.ui.viewmodel

import com.powervision.base.base.BaseViewModel
import com.powervision.http.observer.StateLiveData
import com.powervision.mvvmdemo.ui.model.UserModel
import com.powervision.mvvmdemo.ui.repository.LoginRepository

/**
 * @auth: njb
 * @date: 2021/12/13 14:03
 * @desc: 用户登录VideModel
 */
class LoginViewModel : BaseViewModel() {

    private val repository by lazy { LoginRepository() }

    val userLiveData = StateLiveData<UserModel?>()

    fun login(username: String, password: String) {
        launchWithLoading(requestBlock = {
            repository.userLogin(username, password)
        }, resultCallback = {
            userLiveData.value = it
        })
    }
}